// OverwriteDialog.h

#ifndef __OVERWRITE_DIALOG_H
#define __OVERWRITE_DIALOG_H


#include "resource.h"

namespace NOverwriteDialog
{
  struct CFileInfo
  {
    UINT64 Size;
    FILETIME Time;
    CString Name;
	bool SizeIsDefined;
	bool TimeIsDefined;

    void SetTime(const FILETIME *t)
    {
      if (t == 0)
        TimeIsDefined = false;
      else
      {
        TimeIsDefined = true;
        Time = *t;
      }
    }
    void SetSize(const UINT64 *size)
    {
      if (size == 0)
        SizeIsDefined = false;
      else
      {
        SizeIsDefined = true;
        Size = *size;
      }
    }
	LPCTSTR GetFileSize();
	LPCTSTR GetFileDate();
	CString GetDescription();
	HICON GetIcon();
	void ReduceString(CString &s);

  };
}

class COverwriteDialog: public CDialogImpl<COverwriteDialog>,
						public CWinDataExchange<COverwriteDialog>
{
public:	
	enum { IDD = IDD_DIALOG_OVERWRITE};
	BEGIN_DDX_MAP(COverwriteDialog)
		DDX_CONTROL_HANDLE(IDC_STATIC_OVERWRITE_OLD_FILE_ICON, m_wOldControl)
		DDX_CONTROL_HANDLE(IDC_STATIC_OVERWRITE_NEW_FILE_ICON, m_wNewControl)
		DDX_TEXT(IDC_STATIC_FILE_OVERWRITE_EXISTS, m_strDstFileExists)
		DDX_TEXT(IDC_STATIC_FILE_FROM_TIME, m_strSrcFileDate)
		DDX_TEXT(IDC_STATIC_FILE_TO_TIME, m_strDstFileDate)
		DDX_TEXT(IDC_STATIC_FILE_FROM_SIZE, m_strSrcFileSize)
		DDX_TEXT(IDC_STATIC_FILE_TO_SIZE, m_strDstFileSize)		
	END_DDX_MAP()
	BEGIN_MSG_MAP(COverwriteDialog)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_ID_HANDLER(IDYES, OnButtonCmd)
		COMMAND_ID_HANDLER(IDC_BUTTON_OVERWRITE_YES_TO_ALL, OnButtonCmd)
		COMMAND_ID_HANDLER(IDNO, OnButtonCmd)
		COMMAND_ID_HANDLER(IDC_BUTTON_OVERWRITE_NO_TO_ALL, OnButtonCmd)		
		COMMAND_ID_HANDLER(IDCANCEL, OnButtonCmd)
				
	END_MSG_MAP()

  LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
  LRESULT OnButtonCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
  

private:
	CStatic m_wOldControl;
	CStatic m_wNewControl;
	CString m_strSrcFileSize;
	CString m_strDstFileSize;
	CString m_strSrcFileDate;
	CString m_strDstFileDate;
	CString m_strDstFileExists;
	
public:  
  NOverwriteDialog::CFileInfo OldFileInfo;
  NOverwriteDialog::CFileInfo NewFileInfo;
};

#endif
